/**
 * Copyright (C) 2018-2021
 * All rights reserved, Designed By www.yixiang.co

 */
package co.yixiang.modules.product.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* @author hupeng
* @date 2020-05-12
*/

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("yx_store_product_attr")
public class YxStoreProductAttr implements Serializable {

    @TableId
    private Long id;


    /** 商品ID */
    private Long productId;


    /** 属性名 */
    private String attrName;


    /** 属性值 */
    private String attrValues;

    public static YxStoreProductAttrBuilder builder() {
        return new YxStoreProductAttrBuilder();
    }


    public void copy(YxStoreProductAttr source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static class YxStoreProductAttrBuilder {
        private Long id;
        private Long productId;
        private String attrName;
        private String attrValues;

        YxStoreProductAttrBuilder() {
        }

        public YxStoreProductAttrBuilder id(Long id) {
            this.id = id;
            return this;
        }

        public YxStoreProductAttrBuilder productId(Long productId) {
            this.productId = productId;
            return this;
        }

        public YxStoreProductAttrBuilder attrName(String attrName) {
            this.attrName = attrName;
            return this;
        }

        public YxStoreProductAttrBuilder attrValues(String attrValues) {
            this.attrValues = attrValues;
            return this;
        }

        public YxStoreProductAttr build() {
            return new YxStoreProductAttr(id, productId, attrName, attrValues);
        }

        public String toString() {
            return "YxStoreProductAttr.YxStoreProductAttrBuilder(id=" + this.id + ", productId=" + this.productId + ", attrName=" + this.attrName + ", attrValues=" + this.attrValues + ")";
        }
    }
}
